package com.lzy.wzy.controller;

import com.github.pagehelper.PageInfo;
import com.lzy.wzy.constant.MyConstant;
import com.lzy.wzy.model.ModifyWorkOrderBean;
import com.lzy.wzy.model.OutOfHoursStatisticsBean;
import com.lzy.wzy.model.ProductionManagementHoursBean;
import com.lzy.wzy.model.WorkOrderBean;
import com.lzy.wzy.result.ResponseCode;
import com.lzy.wzy.result.Result;
import com.lzy.wzy.service.TemplateService;
import com.lzy.wzy.service.WorkOrderService;
import com.lzy.wzy.utils.PatternUtils;
import com.lzy.wzy.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


//计划部使用
@RestController
@RequestMapping("/plan")
@Slf4j
public class WorkOrderController {
    @Autowired
    private WorkOrderService workOrderService;

    @Autowired
    private TemplateService templateService;


    /*
     * @Author wzy
     * @Description // 查询所有工单
     * @Date 2021/7/14 10:27
     * @Param * @param: pageNum 当前页
     * @param: pageSize  页大小
     * @return com.lzy.wzy.result.Response<com.github.pagehelper.PageInfo<com.lzy.wzy.model.WorkOrderBean>>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/queryAllWorkOrder", method = RequestMethod.GET)
    public Result<PageInfo<WorkOrderVo>> queryAllWorkOrder(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        log.info("查询所有工单");
        return workOrderService.doQueryAllWorkOrder(pageSize, pageNum);
    }

    /*
     * @Author wzy
     * @Description // 添加工单
     * @Date 2021/7/14 15:33
     * @Param * @param: workOrderBean 工单信息
     * @return com.lzy.wzy.result.Response<org.apache.poi.ss.formula.functions.T>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/addWorkOrder", method = RequestMethod.POST)
    public Result<T> addWorkOrder(@Validated @RequestBody WorkOrderBean workOrderBean) {
        synchronized (MyConstant.Re.r3) {
            log.info("添加新工单");
            return workOrderService.doAddWorkOrder(workOrderBean);
        }
    }


    /*
     * @Author wzy
     * @Description // 修改工单
     * @Date 2021/7/14 15:34
     * @Param * @param: workOrderBean
     * @return com.lzy.wzy.result.Response<org.apache.poi.ss.formula.functions.T>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/modifyWorkOrder", method = RequestMethod.POST)
    public Result<T> modifyWorkOrder(@Validated @RequestBody ModifyWorkOrderBean workOrderBean) {
        log.info("修改工单");
        return workOrderService.doModifyWorkOrderByNo(workOrderBean);
    }

    /*
     * @Author wzy
     * @Description //TODO
     * @Date 2021/7/14 15:35
     * @Param * @param: pageNum
     * @param: pageSize
     * @param: searchValue 搜索框输入值
     * @return com.lzy.wzy.result.Response<com.github.pagehelper.PageInfo<com.lzy.wzy.model.WorkOrderBean>>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/searchWorkOrder", method = RequestMethod.POST)
    public Result<PageInfo<WorkOrderVo>> searchWorkOrder(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "15") int pageSize, @RequestParam(value = "searchValue") String searchValue) {
        log.info("搜索框查询工单");
        if (StringUtils.isBlank(searchValue.trim())) {
            return Result.to(ResponseCode.NPE.getCode(), ResponseCode.NPE.getMsg());
        }
        return workOrderService.doSearch(pageSize, pageNum, searchValue.trim());
    }

    /*
     * @Author wzy
     * @Description // 历史记录查询
     * @Date 2021/7/14 15:35
     * @Param * @param: pageNum
     * @param: pageSize
     * @param: historicalTime 查询时间
     * @return com.lzy.wzy.result.Response<com.github.pagehelper.PageInfo<com.lzy.wzy.model.WorkOrderBean>>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/searchHistoricalTickets", method = RequestMethod.POST)
    public Result<PageInfo<WorkOrderVo>> searchHistoricalTickets(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "15") int pageSize, @NotBlank @RequestParam(value = "historicalTime") String historicalTime) {
        log.info("查询历史工单");
        return workOrderService.doSearchHistoricalTickets(pageSize, pageNum, historicalTime);
    }

    /*
     * @Author wzy
     * @Description // 批量修改工单
     * @Date 2021/7/14 15:36
     * @Param * @param: list
     * @return com.lzy.wzy.result.Response<org.apache.poi.ss.formula.functions.T>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/batchModify", method = RequestMethod.POST)
    public Result<T> batchModify(@NotNull @RequestBody List<ModifyWorkOrderBean> modifyWorkOrderBeans) {
        log.info("批量修改工单");
        return workOrderService.doBatchModifyWorkOrder(modifyWorkOrderBeans);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/queryByStatus", method = RequestMethod.GET)
    public Result<PageInfo<WorkOrderVo>> queryByStatus(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "15") int pageSize, @NotBlank @RequestParam("status") String status) {
        log.info("通过状态查询工单");
        return workOrderService.doQueryWorkOrdersThroughWorkOrderStatus(pageSize, pageNum, status);
    }

    /*
     * @Author wzy
     * @Description //TODO 工单反转
     * @Date 2021/8/6 17:06
     * @Param * @param: workOrderNumber
     * @return com.lzy.wzy.result.Response<org.apache.poi.ss.formula.functions.T>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/caseClosedReversal", method = RequestMethod.GET)
    public Result<T> caseClosedReversal(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        synchronized (MyConstant.Re.re) {
            if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
                return Result.invalidFormat("非法工单");
            }
            log.info("工单反结案");
            return workOrderService.reserveWorkOrder(workOrderNumber);
        }
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/antiFinishedWorkOrder", method = RequestMethod.GET)
    public Result<T> antiFinishedWorkOrder(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        synchronized (MyConstant.Re.r2) {
            if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
                return Result.invalidFormat("非法工单");
            }
            log.info("工单反完工");
            return workOrderService.doAntiFinishedWorkOrder(workOrderNumber);
        }
    }


    /*
     * @Author wzy
     * @Description //TODO 结案被反结案的工单
     * @Date 2021/8/13 9:55
     * @Param * @param: workOrderNumber
     * @return com.lzy.wzy.result.Response<org.apache.poi.ss.formula.functions.T>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/workOrderSettlement", method = RequestMethod.POST)
    public Result<T> workOrderSettlement(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        synchronized (MyConstant.Re.r4) {
            if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
                return Result.invalidFormat("非法工单");
            }
            log.info("工单特殊结案");
            return workOrderService.doWorkOrderSettlement(workOrderNumber);
        }
    }


    //获取半年内的审批结果
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/obtainTheApprovalResultsWithinHalfAYear", method = RequestMethod.GET)
    public Result<PageInfo<ApprovalResultsVo>> obtainTheApprovalResultsWithinHalfAYear(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        log.info("获取半年内的审批结果");
        return workOrderService.doObtainTheApprovalResultsWithinHalfAYear(pageNum, pageSize);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getApprovalDetails", method = RequestMethod.GET)
    public Result<ApprovalDetailsVo> getApprovalDetails(@NotBlank @RequestParam("id") String id) {
        if (!PatternUtils.checkId(id)) {
            return Result.invalidFormat();
        }
        log.info("获取审批详情");
        return workOrderService.doGetApprovalDetails(Integer.parseInt(id));
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getAllPendingExceptionInfo", method = RequestMethod.GET)
    public Result<List<PendingExceptionInfoVo>> getAllPendingExceptionInfo(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat("非法工单");
        }
        log.info("加载待处理异常");
        return workOrderService.doGetAllPendingExceptionInfo(workOrderNumber);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getAllConfirmedExceptionInfo", method = RequestMethod.GET)
    public Result<List<ConfirmedExceptionInfoVo>> getAllConfirmedExceptionInfo(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat("非法工单");
        }
        return workOrderService.doGetAllExceptionInfoByStatus(workOrderNumber, MyConstant.ReportStatus.TOBE_CONFIRMED);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getAllPendingExeExceptionInfo", method = RequestMethod.GET)
    public Result<List<ConfirmedExceptionInfoVo>> getAllPendingExeExceptionInfo(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat("非法工单");
        }
        return workOrderService.doGetAllExceptionInfoByStatus(workOrderNumber, MyConstant.ReportStatus.PENDING_EXECUTE);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT_DIRECTOR','ROLE_PROCESS_ENGINEER','ROLE_QUALITY_ENGINEER','ROLE_ADMIN')")
    @RequestMapping(value = "/exceptionWorkOrderHandling", method = RequestMethod.POST)
    public Result<T> exceptionWorkOrderHandling(@NotBlank @RequestParam("id") String id, @NotBlank @RequestParam("program") String program
            , MultipartFile file, @NotBlank @RequestParam("workOrderNumber") String workOrderNumber) throws Exception {
        if (PatternUtils.checkDigitId(id) || !PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doExceptionWorkOrderHandling(Integer.parseInt(id), program, file, workOrderNumber);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_ADMIN')")
    @RequestMapping(value = "/executionConfirmation", method = RequestMethod.GET)
    public Result<T> executionConfirmation(@NotBlank @RequestParam("id") String id, @NotBlank @RequestParam("exeResult") String exeResult) {
        if (PatternUtils.checkDigitId(id)) {
            return Result.invalidFormat();
        }
        return workOrderService.doExecutionConfirmation(Integer.parseInt(id), exeResult);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN')")
    @RequestMapping(value = "/finalConfirmation", method = RequestMethod.GET)
    public Result<T> finalConfirmation(@NotBlank @RequestParam("id") String id, @NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        if (PatternUtils.checkDigitId(id) || !PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doFinalConfirmation(Integer.parseInt(id), workOrderNumber);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getAllConfirmedExceptionInformation", method = RequestMethod.GET)
    public Result<List<HistoryExceptionVo>> getAllConfirmedExceptionInformation(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat("非法工单");
        }
        return workOrderService.doGetAllConfirmedExceptionInformation(workOrderNumber);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/exceptionInformationQuery", method = RequestMethod.GET)
    public Result<List<HistoryExceptionVo>> exceptionInformationQuery(@NotBlank @RequestParam("searchValue") String searchValue) {
        return workOrderService.doExceptionInformationQuery(searchValue.trim());
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/deleteWorkOrder", method = RequestMethod.GET)
    public Result<T> deleteWorkOrder(@NotBlank @RequestParam("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat("非法工单");
        }
        return workOrderService.doDeleteWorkOrder(workOrderNumber);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/statisticsOfFinishedMachines", method = RequestMethod.GET)
    public Result<List<EchartsVo>> statisticsOfFinishedMachines(@NotBlank @RequestParam("year") String year,
                                                                @NotBlank @RequestParam("month") String month,
                                                                @NotBlank @RequestParam("productCode") String productCode
            , @NotBlank @RequestParam("day") String day) {
        if (PatternUtils.checkDigitId(year) || PatternUtils.checkDigitId(month) || PatternUtils.checkDigitId(day)) {
            return Result.invalidFormat();
        }
        return templateService.doStatisticsOfFinishedMachines(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), productCode);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/annualReportExport", method = RequestMethod.GET)
    public void annualReportExport(HttpServletResponse response, @NotBlank @RequestParam("year") String year) throws Exception {
        templateService.doProductionReportExport(response, Integer.parseInt(year), 0, 0, 2);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/monthlyReportExport", method = RequestMethod.GET)
    public void monthlyReportExport(HttpServletResponse response, @NotBlank @RequestParam("year") String year,
                                    @NotBlank @RequestParam("month") String month) throws Exception {
        if (PatternUtils.checkDigitId(year) || PatternUtils.checkDigitId(month)) {
            throw new RuntimeException("非法日期");
        }
        templateService.doProductionReportExport(response, Integer.parseInt(year), Integer.parseInt(month), 0, 3);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/dayReportExport", method = RequestMethod.GET)
    public void dayReportExport(HttpServletResponse response,
                                @NotBlank @RequestParam("year") String year,
                                @NotBlank @RequestParam("month") String month,
                                @NotBlank @RequestParam("day") String day) throws Exception {
        if (PatternUtils.checkDigitId(year) || PatternUtils.checkDigitId(month) || PatternUtils.checkDigitId(day)) {
            throw new RuntimeException("非法日期");
        }
        templateService.doProductionReportExport(response, Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), 4);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getApprovalResult", method = RequestMethod.GET)
    public Result<List<ApprovalResultsVo>> getApprovalResult() {
        return workOrderService.doGetApprovalResult();
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/init", method = RequestMethod.GET)
    public Result<IndexVo> init() {
        return workOrderService.doInit();
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/download/{id}/{idf}", method = RequestMethod.GET)
    public void downloadAttachments(HttpServletResponse response, @NotBlank @PathVariable("id") String id, @PathVariable("idf") int idf) throws IOException {
        if (PatternUtils.checkDigitId(id)) {
            throw new NumberFormatException("非法id");
        }
        workOrderService.doDownloadAttachments(response, Integer.parseInt(id), idf);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_QUALITY','QUALITY_INSPECTION')")
    @RequestMapping(value = "/transfer/{id}", method = RequestMethod.GET)
    public Result<T> transfer(@NotBlank @PathVariable("id") String id) {
        synchronized (MyConstant.Re.r5) {
            if (PatternUtils.checkDigitId(id)) {
                return Result.invalidFormat();
            }
            return workOrderService.doTransfer(Integer.parseInt(id));
        }
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_ADMIN')")
    @RequestMapping(value = "/getFileSuffix/{id}/{idf}", method = RequestMethod.GET)
    public Result<String> getFileSuffix(@NotBlank @PathVariable("id") String id, @NotBlank @PathVariable("idf") int idf) {
        if (PatternUtils.checkDigitId(id)) {
            return Result.invalidFormat();
        }
        return workOrderService.doGetFileSuffix(Integer.parseInt(id), idf);
    }

    /*
     * @Author wzy
     * @Description //TODO 获取审批人签字
     * @Date 2021/10/11 15:11
     * @Param * @param: workOrderNumber
     * @return com.lzy.wzy.result.Response<java.util.List<com.lzy.wzy.vo.ApproveSignVo>>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN')")
    @RequestMapping(value = "/getApproveSign/{workOrderNumber}", method = RequestMethod.GET)
    public Result<List<ApproveSignVo>> getApproveSign(@NotBlank @PathVariable("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doObtainTheSignatureOfTheApprover(workOrderNumber);
    }

    //上报重大异常
    @PreAuthorize("hasAnyAuthority('ROLE_QUALITY_ENGINEER')")
    @RequestMapping(value = "/reportAMajorException/{workOrderNumber}/{id}", method = RequestMethod.GET)
    public Result<T> reportAMajorException(@NotBlank @PathVariable("workOrderNumber") String workOrderNumber,@PathVariable("id")int id) {
        synchronized (MyConstant.Re.re) {
            if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
                return Result.invalidFormat("非法工单");
            }
            return workOrderService.doReportAMajorException(workOrderNumber,id);
        }
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getAllWorkOrderNumber", method = RequestMethod.GET)
    public Result<List<String>> getAllWorkOrderNumber() {
        return workOrderService.doObtainAllOutstandingWorkOrderNumbers();
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getWorkingHoursInfo/{workOrderNumber}", method = RequestMethod.GET)
    public Result<WorkOrderPartInfo> getWorkingHoursInfo(@NotBlank @PathVariable("workOrderNumber") String workOrderNumber) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doObtainPartOfWorkOrderInformation(workOrderNumber);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_PLAN','ROLE_CRAFT','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getAllProjectNumber", method = RequestMethod.GET)
    public Result<List<KeyValueVo>> getAllProjectNumber() {
        return workOrderService.doGetAllProjectNumber();
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_PLAN','ROLE_CRAFT','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getProjectInfo/{projectNumber}", method = RequestMethod.GET)
    public Result<String> getProjectInfo(@NotBlank @PathVariable("projectNumber") String projectNumber) {
        return workOrderService.doGetProjectInfo(projectNumber);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN')")
    @RequestMapping(value = "/saveProjectInfo", method = RequestMethod.POST)
    public Result<T> saveProjectInfo(@Validated @RequestBody OutOfHoursStatisticsBean outOfHoursStatisticsBean) {
        return workOrderService.doSaveProjectInfo(outOfHoursStatisticsBean);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_CRAFT','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN')")
    @RequestMapping(value = "/saveAttTimeInfo", method = RequestMethod.POST)
    public Result<T> saveAttTimeInfo(@Validated @RequestBody ProductionManagementHoursBean productionManagementHoursBean) {
        return workOrderService.doSaveAttTime(productionManagementHoursBean);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/obtainProductionTimeInformation", method = RequestMethod.GET)
    public Result<PageInfo<WorkingHoursVo>> obtainProductionTimeInformation(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        return workOrderService.doObtainProductionTimeInformation(pageNum, pageSize);
    }

    /*
     * @Author wzy
     * @Description //TODO 获取所有非生产项目工时信息
     * @Date 2021/10/18 16:13
     * @Param * @param: pageNum
     * @param: pageSize
     * @return com.lzy.wzy.result.Response<com.github.pagehelper.PageInfo<com.lzy.wzy.vo.OutOfHoursStatisticsVo>>
     **/
    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/obtainTimeInformationOfAllProjects", method = RequestMethod.GET)
    public Result<PageInfo<OutOfHoursStatisticsVo>> obtainTimeInformationOfAllProjects(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        return workOrderService.doObtainTimeInformationOfAllProjects(pageNum, pageSize);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN')")
    @RequestMapping(value = "/saveProductionTimeInformation", method = RequestMethod.POST)
    public Result<T> saveProductionTimeInformation(@Validated @RequestBody WorkingHoursVo workingHoursVo) {
        return workOrderService.doSaveProductionTimeInformation(workingHoursVo);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping("/queryHoursByWorkNumber/{workOrderNumber}/{pageNum}/{pageSize}")
    public Result<PageInfo<WorkingHoursVo>> queryHoursByWorkNumber(@NotBlank @PathVariable("workOrderNumber") String workOrderNumber,
                                                                   @NotBlank @PathVariable("pageNum") int pageNum, @NotBlank @PathVariable("pageSize") int pageSize) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doQueryHoursByWorkNumber(workOrderNumber.trim(), pageNum, pageSize);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getProductHoursByMonth/{year}/{month}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> getProductHoursByMonth(@NotNull @PathVariable("year") int year, @NotNull @PathVariable("month") int month) {
        return workOrderService.doMonthlyStatisticsOfProductionHours(year, month);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getProductHoursByYear/{year}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> getProductHoursByYear(@NotNull @PathVariable("year") int year) {
        return workOrderService.doYearStatisticsOfProductionHours(year);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getMonthProductHoursByNumber/{workOrderNumber}/{year}/{month}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> getMonthProductHoursByNumber(@NotNull @PathVariable("workOrderNumber") String workOrderNumber,
                                                                        @NotNull @PathVariable("year") int year, @NotNull @PathVariable("month") int month) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doWorkOrderNumberMonthStatisticsOfProductionHours(workOrderNumber, year, month);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getYearProductHoursByNumber/{workOrderNumber}/{year}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> getYearProductHoursByNumber(@NotBlank @PathVariable("workOrderNumber") String workOrderNumber,
                                                                       @NotNull @PathVariable("year") int year) {
        if (!PatternUtils.checkWorkOrderNumber(workOrderNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doWorkOrderNumberYearStatisticsOfProductionHours(workOrderNumber, year);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getProjectInfoByNumberOrName", method = RequestMethod.GET)
    public Result<PageInfo<OutOfHoursStatisticsVo>> getProjectInfoByNumberOrName(@NotBlank @RequestParam("searchValue") String searchValue,
                                                                                 @NotBlank @RequestParam("pageNum") int pageNum, @NotBlank @RequestParam("pageSize") int pageSize) {
        return workOrderService.doQueryProjectInformationByProjectNumberOrProjectName(searchValue, pageNum, pageSize);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/monthlyStatisticsOfProjectHours/{year}/{month}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> monthlyStatisticsOfProjectHours(@NotNull @PathVariable("year") int year, @NotNull @PathVariable("month") int month) {
        return workOrderService.doMonthlyStatisticsOfProjectHours(year, month);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/yearStatisticsOfProjectHours/{year}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> yearStatisticsOfProjectHours(@NotNull @PathVariable("year") int year) {
        return workOrderService.doYearStatisticsOfProjectHours(year);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/projectNumberMonthStatisticsOfProjectHours/{projectNumber}/{year}/{month}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> projectNumberMonthStatisticsOfProjectHours(@NotBlank @PathVariable("projectNumber") String projectNumber,
                                                                                      @PathVariable("year") int year, @PathVariable("month") int month) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doProjectNumberMonthStatisticsOfProjectHours(projectNumber, year, month);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/projectNumberYearStatisticsOfProjectHours/{projectNumber}/{year}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> projectNumberYearStatisticsOfProjectHours(@NotBlank @PathVariable("projectNumber") String projectNumber, @PathVariable("year") int year) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doProjectNumberYearStatisticsOfProjectHours(projectNumber, year);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN')")
    @RequestMapping(value = "/addProject", method = RequestMethod.POST)
    public Result<T> addProject(@NotBlank @RequestParam("projectNumber") String projectNumber, @NotBlank @RequestParam("projectName") String projectName) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doAddProject(projectNumber, projectName);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_PLAN','ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getProjectInfoByProjectNumber/{projectNumber}", method = RequestMethod.GET)
    public Result<String> getProjectInfoByProjectNumber(@NotBlank @PathVariable("projectNumber") String projectNumber) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doGetProjectInfoByProjectNumber(projectNumber);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_PRODUCE_DIRECTOR','ROLE_SUPERVISOR','ROLE_ADMIN')")
    @RequestMapping(value = "/deleteProject/{projectNumber}", method = RequestMethod.GET)
    public Result<T> deleteProject(@NotBlank @PathVariable("projectNumber") String projectNumber) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doDeleteProject(projectNumber);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/manageTimeStatisticsByMonth/{idf}/{year}/{month}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> manageTimeStatisticsByMonth(@NotNull @PathVariable("year") int year, @NotNull @PathVariable("month") int month,
                                                                       @PathVariable("idf") int idf) {

        return workOrderService.doManageTimeStatisticsByMonth(year, month, idf);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/manageTimeStatisticsByYear/{idf}/{year}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> manageTimeStatisticsByYear(@NotNull @PathVariable("year") int year, @PathVariable("idf") int idf) {

        return workOrderService.doManageTimeStatisticsByYear(year, idf);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/monthlyManagementTimeStatisticsByNumber/{idf}/{projectNumber}/{year}/{month}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> monthlyManagementTimeStatisticsByNumber(@NotBlank @PathVariable("projectNumber") String projectNumber,
                                                                                   @PathVariable("year") int year, @PathVariable("month") int month, @PathVariable("idf") int idf) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doMonthlyManagementTimeStatisticsByNumber(projectNumber, year, month, idf);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/yearManagementTimeStatisticsByNumber/{idf}/{projectNumber}/{year}", method = RequestMethod.GET)
    public Result<StatisticsHoursResultVo> yearManagementTimeStatisticsByNumber(@NotBlank @PathVariable("projectNumber") String projectNumber,
                                                                                @PathVariable("year") int year, @PathVariable("idf") int idf) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doYearManagementTimeStatisticsByNumber(projectNumber, year, idf);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/allThePeopleManagementTimeReport/{idf}/{year}/{month}", method = RequestMethod.GET)
    public void allThePeopleManagementTimeReport(@PathVariable("year") int year, @PathVariable("month") int month, @PathVariable("idf") int idf, HttpServletResponse response) throws IOException {
        workOrderService.doAllThePeopleManagementTimeReport(idf, year, month, response);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/personManagementTimeReport/{idf}/{year}/{month}", method = RequestMethod.GET)
    public void personManagementTimeReport(@PathVariable("year") int year, @PathVariable("month") int month, @PathVariable("idf") int idf, HttpServletResponse response) throws IOException {
        workOrderService.doPersonalManagementTimeReport(idf, year, month, response);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/getPersonalAllManageWorkingHoursInfo/{pageNum}/{pageSize}", method = RequestMethod.GET)
    public Result<PageInfo<ManageWorkingTimeVo>> getPersonalAllManageWorkingHoursInfo(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize) {
        return workOrderService.doQueryAllManagementTimeInformationOfAnIndividual(pageNum, pageSize);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_ADMIN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_OTHER')")
    @RequestMapping(value = "/getPersonalAllManageWorkingHoursInfoByProjectNumber/{projectNumber}/{jobNumber}/{pageNum}/{pageSize}", method = RequestMethod.GET)
    public Result<PageInfo<ManageWorkingTimeVo>> getPersonalAllManageWorkingHoursInfoByProjectNumber(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize,
                                                                                                     @PathVariable("projectNumber") String projectNumber, @PathVariable("jobNumber") String jobNumber) {
        if (PatternUtils.checkProjectNumber(projectNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doQueryAllManagementTimeInformationOfAnIndividualByProjectNumber(pageNum, pageSize, projectNumber, jobNumber);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getPersonalAllManageWorkingHoursInfoByJobNumber/{jobNumber}/{pageNum}/{pageSize}", method = RequestMethod.GET)
    public Result<PageInfo<ManageWorkingTimeVo>> getPersonalAllManageWorkingHoursInfoByJobNumber(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize,
                                                                                                 @PathVariable("jobNumber") String jobNumber) {
        if (PatternUtils.checkProjectNumber(jobNumber)) {
            return Result.invalidFormat();
        }
        return workOrderService.doQueryAllManagementTimeInformationOfAnIndividualByJobNumber(pageNum, pageSize, jobNumber);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/exportOfAnnualProductionHours/{year}", method = RequestMethod.GET)
    public void exportOfAnnualProductionHours(@PathVariable("year") int year, HttpServletResponse response) throws IOException {
        workOrderService.doExportOfAnnualProductionHours(year, response);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/exportOfMonthlyProductionHours/{year}/{month}", method = RequestMethod.GET)
    public void exportOfMonthlyProductionHours(@PathVariable("year") int year, @PathVariable("month") int month, HttpServletResponse response) throws IOException {
        workOrderService.doExportOfMonthlyProductionHours(year, month, response);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/exportOfAnnualProjectHours/{year}", method = RequestMethod.GET)
    public void exportOfAnnualProjectHours(@PathVariable("year") int year, HttpServletResponse response) throws IOException {
        workOrderService.doExportOfAnnualProjectHours(year, response);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/exportOfMonthlyProjectHours/{year}/{month}", method = RequestMethod.GET)
    public void exportOfMonthlyProjectHours(@PathVariable("year") int year, @PathVariable("month") int month, HttpServletResponse response) throws IOException {
        workOrderService.doExportOfMonthlyProjectHours(year, month, response);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/exportPersonalOfAnnualManagementHours/{jobNumber}/{year}", method = RequestMethod.GET)
    public void exportPersonalOfAnnualManagementHours(@PathVariable("year") int year, @PathVariable("jobNumber") String jobNumber, HttpServletResponse response) throws IOException {
        workOrderService.doExportPersonalOfAnnualManagementHours(year, jobNumber, response);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/exportPersonalOfMonthlyManagementHours/{jobNumber}/{year}/{month}", method = RequestMethod.GET)
    public void exportPersonalOfMonthlyManagementHours(@PathVariable("year") int year, @PathVariable("month") int month, @PathVariable("jobNumber") String jobNumber,
                                                       HttpServletResponse response) throws IOException {
        workOrderService.doExportPersonalOfMonthlyManagementHours(year, month, jobNumber, response);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')")
    @RequestMapping(value = "/delProductionHours/{id}", method = RequestMethod.GET)
    public Result<T> delProductionHours(@PathVariable("id") int id) {
        return workOrderService.doAccordingToDeleteProductionHours(id);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')")
    @RequestMapping(value = "/delProjectHours/{id}", method = RequestMethod.GET)
    public Result<T> delProjectHours(@PathVariable("id") int id) {
        return workOrderService.doAccordingToDeleteNonProductionHours(id);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')")
    @RequestMapping(value = "/delManagementHours/{id}", method = RequestMethod.GET)
    public Result<T> delManagementHours(@PathVariable("id") int id) {
        return workOrderService.doAccordingToDeleteManagementHours(id);
    }

    @RequestMapping(value = "/getCurMonthManageWorkingHoursInfo/{time}/{pageNum}/{val}", method = RequestMethod.GET)
    public Result<PageInfo<ManageWorkingTimeVo>> getCurMonthManageWorkingHoursInfo(@PathVariable("time") String time, @PathVariable("pageNum") int pageNum
            , @PathVariable("val") String val) {
        List<String> list = SecurityContextHolder.getContext().getAuthentication().getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
        if (Arrays.stream(MyConstant.ApproveGroup.manage).noneMatch(list::contains)) {
            val = null;
        }
        try {
            DateTimeFormatter.ofPattern("yyyy-MM").parse(time);
        } catch (Exception e) {
            throw new RuntimeException("非法日期");
        }
        return workOrderService.doGetCurMonthManageWorkingHoursInfo(time, pageNum, val);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/searchTicketInfo", method = RequestMethod.GET)
    public Result<List<TicketVo>> searchTicketInfo(@NotBlank @RequestParam("val") String val) {
        return workOrderService.doGetSearchInfo(val);
    }


    @PreAuthorize("hasAnyAuthority('ROLE_CRAFT','ROLE_PLAN','ROLE_PRODUCE','ROLE_QUALITY','QUALITY_INSPECTION','ROLE_ADMIN','ROLE_OTHER')")
    @RequestMapping(value = "/getVideoLink", method = RequestMethod.GET)
    public Result<Set<String>> getVideoLink(){
        return workOrderService.doGetVideoLink();
    }

}
